import request from '@/utils/request'
import { getItem } from '@/utils/auth'
import { isNotEmpty } from '@/utils'

export function fetchSystemDefineList(data) {
  return request({
    url: '/cloud-system/getSystemDefineList',
    method: 'post',
    data
  })
}

export function fetchSystemDefineOne(data) {
  return request({
    url: '/cloud-system/getOneSystemDefineDetail',
    method: 'post',
    data
  })
}

export function createSystemDefine(data) {
  return request({
    url: '/cloud-system/createOneSystemDefine',
    method: 'post',
    data
  })
}

export function updateSystemDefine(data) {
  return request({
    url: '/cloud-system/updateOneSystemDefine',
    method: 'post',
    data
  })
}

export function deleteSystemDefine(data) {
  return request({
    url: '/cloud-system/deleteOneSystemDefine',
    method: 'post',
    data
  })
}
export function batchDeleteSystemDefine(data) {
  return request({
    url: '/cloud-system/batchDeleteSystemDefine',
    method: 'post',
    data
  })
}

export function lockSystemDefine(data) {
  return request({
    url: '/cloud-system/lockOneSystemDefine',
    method: 'post',
    data
  })
}

export function unlockSystemDefine(data) {
  return request({
    url: '/cloud-system/unlockOneSystemDefine',
    method: 'post',
    data
  })
}

export function batchLockSystemDefine(data) {
  return request({
    url: '/cloud-system/batchLockSystemDefine',
    method: 'post',
    data
  })
}

export function batchUnLockSystemDefine(data) {
  return request({
    url: '/cloud-system/batchUnLockSystemDefine',
    method: 'post',
    data
  })
}

export function getTimerDefineList(parameter, result) {
  const data = JSON.parse(getItem('baseParam'))
  // data.orderArray = 'orderSeq=1'
  if (isNotEmpty(parameter)) {
    data.parameterArray += (',' + parameter)
  }
  if (isNotEmpty(result)) {
    data.resultArray += (',' + result)
  }
  return request({
    url: '/cloud-weixing/getTimerDefineList',
    method: 'post',
    data
  })
}

export function getSystemLogList(data) {
  return request({
    url: '/cloud-system/getSystemLogList',
    method: 'post',
    data
  })
}

export function getObjectDefineList(parameter, result) {
  const data = JSON.parse(getItem('baseParam'))
  // data.orderArray = 'orderSeq=1'
  if (isNotEmpty(parameter)) {
    data.parameterArray += (',' + parameter)
  }
  if (isNotEmpty(result)) {
    data.resultArray += (',' + result)
  }
  return request({
    url: '/cloud-system/getObjectDefineList',
    method: 'post',
    data
  })
}
